function M = clear_small_values(M, eps)
    mask = abs(real(M)) < eps;
    M(mask) = 1i*imag(M(mask));
    mask = abs(imag(M)) < eps;
    M(mask) = real(M(mask));
end
